/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author edgar
 */
@Entity
@Table(name = "ventas_detalle")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "VentasDetalle.findAll", query = "SELECT v FROM VentasDetalle v"),
    @NamedQuery(name = "VentasDetalle.findByNroFactura", query = "SELECT v FROM VentasDetalle v WHERE v.ventasDetallePK.nroFactura = :nroFactura"),
    @NamedQuery(name = "VentasDetalle.findByNroLinea", query = "SELECT v FROM VentasDetalle v WHERE v.ventasDetallePK.nroLinea = :nroLinea"),
    @NamedQuery(name = "VentasDetalle.findByCantidad", query = "SELECT v FROM VentasDetalle v WHERE v.cantidad = :cantidad"),
    @NamedQuery(name = "VentasDetalle.findByPrecio", query = "SELECT v FROM VentasDetalle v WHERE v.precio = :precio")})
public class VentasDetalle implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected VentasDetallePK ventasDetallePK;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "cantidad")
    private Float cantidad;
    @Column(name = "precio")
    private Integer precio;
    @JoinColumn(name = "nro_factura", referencedColumnName = "nro_factura", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private VentasCabecera ventasCabecera;
    @JoinColumn(name = "cod_articulo", referencedColumnName = "cod_articulo")
    @ManyToOne
    private Articulos codArticulo;

    public VentasDetalle() {
    }

    public VentasDetalle(VentasDetallePK ventasDetallePK) {
        this.ventasDetallePK = ventasDetallePK;
    }

    public VentasDetalle(int nroFactura, int nroLinea) {
        this.ventasDetallePK = new VentasDetallePK(nroFactura, nroLinea);
    }

    public VentasDetallePK getVentasDetallePK() {
        return ventasDetallePK;
    }

    public void setVentasDetallePK(VentasDetallePK ventasDetallePK) {
        this.ventasDetallePK = ventasDetallePK;
    }

    public Float getCantidad() {
        return cantidad;
    }

    public void setCantidad(Float cantidad) {
        this.cantidad = cantidad;
    }

    public Integer getPrecio() {
        return precio;
    }

    public void setPrecio(Integer precio) {
        this.precio = precio;
    }

    public VentasCabecera getVentasCabecera() {
        return ventasCabecera;
    }

    public void setVentasCabecera(VentasCabecera ventasCabecera) {
        this.ventasCabecera = ventasCabecera;
    }

    public Articulos getCodArticulo() {
        return codArticulo;
    }

    public void setCodArticulo(Articulos codArticulo) {
        this.codArticulo = codArticulo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ventasDetallePK != null ? ventasDetallePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof VentasDetalle)) {
            return false;
        }
        VentasDetalle other = (VentasDetalle) object;
        if ((this.ventasDetallePK == null && other.ventasDetallePK != null) || (this.ventasDetallePK != null && !this.ventasDetallePK.equals(other.ventasDetallePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.VentasDetalle[ ventasDetallePK=" + ventasDetallePK + " ]";
    }
    
}
